

public class Chat implements ChatInterface
{
	private static ChatGUI gui;
	private static TCPClientPart tcpC;
	private static Thread t1;

	
	public static void main(String args[]) {
		
		ChatGUI.create("Chat example", new Chat());
	
	}

	public void setGUI(ChatGUI gui) {
		this.gui = gui;
	}

	public void connectChatServer(String host, String port, String nickname) {
			tcpC = new TCPClientPart(gui);
			gui.setChatEnabled(true);
			gui.setChatTitle("Chat: "+host+" : "+port);

			
			gui.println("Chat server: " + host);
			gui.setSelectedTab(1);
			tcpC.clientConnect(host, port, nickname);
			tcpC.checkCapability();
			t1 = new Thread(tcpC);
			t1.start();

	}

	public void disconnectChatServer() {


		tcpC.quit();
	}

	public void send(String text) { 
		
//		if(!tcpC.isChanging()){

			tcpC.sendMsg(text);
//		}
//		else{
//			gui.println("You may not send messages until your name change has been confirmed by server");
//		}
		
		
	}


	
}


